/*By Terrorblade*/
#include "StdAfx.h"
#include "Setup.h"

static bool bypassCombat = false;
//bool rezzon = true; 

static string evon = "#eventon";
static string evoff = "#eventoff";
static string evpPlayer = "#event";
static string maincity = "#maincity";
//static string rezzcmd = "#res";
static string mall = "#mall";

static bool eon = false;
static uint32 emapid = 0;
static float ex = 0.0f;
static float ey = 0.0f;
static float ez = 0.0f;

void EventChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
	if(Message == evon && pPlayer->GetSession()->HasGMPermissions())
{
eon = true;
ex = pPlayer->GetPositionX();
ey = pPlayer->GetPositionY();
ez = pPlayer->GetPositionZ();
emapid = pPlayer->GetMapId();
char message[200];
sprintf(message, "%s has started an event type #event to teleport to the event.", pPlayer->GetName());
sWorld.SendWorldWideScreenText(message);
} 
else if(Message == evoff && pPlayer->GetSession()->HasGMPermissions())
{
eon = false;
char message[200];
sprintf(message, "%s has now ended the event signup", pPlayer->GetName());
sWorld.SendWorldWideScreenText(message);
}
else if(Message == evpPlayer)
{
if(eon)
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
pPlayer->EventTeleport(emapid, ex, ey, ez);
else
pPlayer->BroadcastMessage("You can't port while in combat.");
else
pPlayer->BroadcastMessage("Sorry mate there is no event on right now.");
}
else if(Message == maincity)
{
if(pPlayer->getRace()== 10||pPlayer->getRace()== 2||pPlayer->getRace()== 6||pPlayer->getRace()== 8||pPlayer->getRace()== 5)
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
pPlayer->EventTeleport(1, 1502.709961, -4415.419922, 21.553234);
else
pPlayer->EventTeleport(0, -8913.230469, 554.632996, 93.795029);
else
pPlayer->BroadcastMessage("You can't port while in combat.");
}
/*#rezz-Command - Start
if(Message == rezzcmd)
{
if(rezzon)
if( rezzon )
{ //You can add parameters where reviing is enabled here. e.g. for allowing it only on kalimdor and in Zone 123: (pPlayer->GetMapId() == 1 || pPlayer->GetZoneId() == 123)
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
if (pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE)>=7500) //Will cost 75 Silver (check if enough money)
{
pPlayer->SetUInt32Value(PLAYER_FIELD_COINAGE,(pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE) - 7500)); //Here 75 Silver is removed
sEventMgr.AddEvent(pPlayer, &Player::RemoteRevive, EVENT_PLAYER_REST, 1, 1,0);
} else pPlayer->BroadcastMessage("You don't have 75 silver in your backpack.");
} else
pPlayer->BroadcastMessage("Your in combat!");
else
pPlayer->BroadcastMessage("You can't revive here!.");
}
//#rezz-Command end.*/

else if(Message == mall)
{
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
pPlayer->BroadcastMessage("You can't port while in combat.");
else
if( pPlayer->GetTeam() == 1 )
pPlayer->EventTeleport(0, 3365.120117, -4235.759766, 160.072998); 
else
pPlayer->EventTeleport(0, 234.485184, -2772.871582, 123.364342); 
}
}


void SetupEventChat(ScriptMgr * mgr)
{
   mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &EventChat);
}

